package gowcage.slidemenu;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import com.gowcage.testandroid.R;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import gowcage.slidemenu.custom.SlidingMenu;

/**
 * Created by Administrator on 2017/4/13.
 * 使用自定义侧滑菜单控件
 */

public class SlidingMenuActivity extends Activity {

    @BindView(R.id.slidingmenu_btn_toggle)
    Button btn_toggle;
    @BindView(R.id.slidingMenu)
    SlidingMenu slidingMenu;
//    @BindView(R.id.slidingmenu_listview)
//    ListView listview;
    private ListView listview;

    private Context context;
    private ListViewAdapter adapter;
    private ArrayList<String> dataList = new ArrayList<String>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slidingmenu);
        context = this;
        ButterKnife.bind(this);

        initData();
        listview = (ListView) findViewById(R.id.slidingmenu_listview);
        adapter = new ListViewAdapter(context,dataList);
//        ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, dataList);
        listview.setAdapter(adapter);
    }

    private void initData() {
        for (int i = 'A'; i <= 'Z'; i++) {
            dataList.add((char) i + "");
        }
    }

    @OnClick({R.id.slidingmenu_btn_toggle})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.slidingmenu_btn_toggle:
                slidingMenu.toggle();
                break;
        }
    }

}
